<template>

	<view class="content index-bg" style=" height:100%;display: flex;flex-direction: column;">

		<view class="" style="z-index: 11;">
			<image src="../../static/indexbannerbj.png" style="width: 100%;" mode="widthFix"></image>
		</view>

		<view class=""
			style="margin-left: 15px;margin-right: 15px;margin-bottom: 15px;margin-top: 5px; background-color: #FFFFFF;height: 286px;border-radius: 8px;"
			v-show="zcshow">
			<view class="" style="padding: 15px;display: flex;flex-direction: row;justify-content: center;">
				<text style="font-size: 13px;color: #333333;">— 分期还款0手续费，提前还款减免利息 —</text>
			</view>



			<view class="" :style='this.time == 12 ? cardbackcolorsel:cardbackcolorunsel' @click="choose(12)">
				<view class="" style="display: flex;flex-direction: column;">
					<view class="" style="display: flex;flex-direction: row;align-items: center;margin-bottom: 8px;">
						<text :style="time == 12? fenhuansel:fenhuanunsel">分12个月还</text>
						<image src="../../static/indexfier1.png" mode="" style="width: 12px;height: 14px;"></image>

					</view>
					<view class="" style="display: flex;flex-direction: row;">
						<text :style="time == 12? shouhuansel:shouhuanunsel">首期还￥{{firstBack12}}</text>
						<text :style="time == 12? lixisel:lixiunsel">总利息￥{{lixi12}}</text>
					</view>

				</view>

				<image :src="time == 12? '../../static/indexbtnsel.png' :'../../static/indexbtnunsel.png'" mode=""
					style="width: 18px; height: 18px;"></image>
			</view>

			<view class="" style="height: 10px;"></view>

			<view class="" :style='this.time == 6 ? cardbackcolorsel:cardbackcolorunsel' @click="choose(6)">
				<view class="" style="display: flex;flex-direction: column;">
					<view class="" style="display: flex;flex-direction: row;align-items: center;margin-bottom: 8px;">
						<text :style="time == 6? fenhuansel:fenhuanunsel">分6个月还</text>
						<image src="../../static/indexfier2.png" mode="" style="width: 12px;height: 14px;"></image>


					</view>
					<view class="" style="display: flex;flex-direction: row;">
						<text :style="time == 6? shouhuansel:shouhuanunsel">首期还￥{{firstBack6}}</text>
						<text :style="time == 6? lixisel:lixiunsel">总利息￥{{lixi6}}</text>
					</view>

				</view>

				<image :src="time == 6? '../../static/indexbtnsel.png' :'../../static/indexbtnunsel.png'" mode=""
					style="width: 18px; height: 18px;"></image>
			</view>
			<view class="" style="height: 10px;"></view>

			<view class="" :style='this.time == 3 ? cardbackcolorsel:cardbackcolorunsel' @click="choose(3)">
				<view class="" style="display: flex;flex-direction: column;">
					<view class="" style="display: flex;flex-direction: row;align-items: center;margin-bottom: 8px;">
						<text :style="time == 3? fenhuansel:fenhuanunsel">分3个月还</text>
						<image src="../../static/indexfier3.png" mode="" style="width: 12px;height: 14px;"></image>


					</view>
					<view class="" style="display: flex;flex-direction: row;">
						<text :style="time == 3? shouhuansel:shouhuanunsel">首期还￥{{firstBack3}}</text>
						<text :style="time == 3? lixisel:lixiunsel">总利息￥{{lixi3}}</text>
					</view>

				</view>

				<image :src="time == 3? '../../static/indexbtnsel.png' :'../../static/indexbtnunsel.png'" mode=""
					style="width: 18px; height: 18px;"></image>
			</view>



		</view>

		<view class="" :style="isChargeType ? {height: '100px'} : {minHeight: '170px'}"
			style="background-color: #FFFFFF;border-radius: 8px;margin-left: 15px;margin-right: 15px;">

			<!-- <view class=""
				style="display: flex;flex-direction: row;justify-content: space-between;height: 44px;align-items: center;padding-left: 20px;padding-right: 20px;">
				<text style="color:#848484 ;font-size: 14px;">优惠券</text>
				<view class="" style="display: flex;flex-direction: row;align-items: center;">
					<text style="font-size: 14px;color: #E20707;font-weight: 600;margin-right: 5px;">-￥50</text>
				</view>
			</view>
			<view class="" style="height: 1px;background-color: #F2F2F2;margin-left: 15px;margin-right: 15px;">

			</view>
			<view v-if="!isChargeType" class=""
				style="display: flex;flex-direction: row;justify-content: space-between;height: 44px;align-items: center;padding-left: 20px;padding-right: 20px;">
				<text style="color:#848484 ;font-size: 14px;">收/还款账户</text>
				<view class="" style="display: flex;flex-direction: row;align-items: center;">
					<image src="../../static/cards.png" mode="" style="width: 90px;height: 25px;"></image>
				</view>
			</view> -->
			<view class="" style="height: 60rpx;">
				
			</view>

			<view v-if="!isChargeType" class=""
				style="margin-left: 16px;;margin-right: 16px;height: 45px;background-color: #F0F3F6;display: flex;flex-direction: row;align-items: center;padding-left: 14px;border-radius: 6px;">
				<text style="color: #333333;margin-right:15px ;">手机号:</text>
				<input type="text" @click="inputClickHandler" :always-system="true" v-model="phone" @input="phoneInput"
					maxlength="13" placeholder="请输入手机号" placeholder-style="color:#999999" />

			</view>

			<view v-if="!isChargeType && itemList.length && false" class=""
				style="margin-left: 16px;margin-right: 16px;">
				<view class="" style="margin-top: 10px; color: rgb(132, 132, 132); font-size: 14px;">
					<text>芝麻分</text>
				</view>
				<!-- <axb-check-box ref="radio3" :list="itemList" @change="radioChangeType"></axb-check-box> -->
				<view class="" style="display: flex; flex-wrap: wrap;">
					<view v-for="item in itemList" @click="radioChangeType(item.value)" class=""
						:style="  zhima== item.value ?   {
							background: 'rgb(213, 228, 253)',
							color: 'rgb(60, 126, 246)',
							borderColor: 'rgb(60, 126, 246)',
						} : {
							background: 'rgb(247, 247, 247)',
							color: 'rgb(125, 125, 125)',
						}"
						style="padding: 6px 12px; margin-right: 4px; margin-top: 10px;font-size: 14px;border-radius: 9999px;">
						{{ item.name }}
					</view>
				</view>
			</view>

			<view
				style="margin-top:15px;margin-left: 15px ;margin-right: 15px;height: 53px;color: #FFFFFF;display: flex;flex-direction: row;justify-content: center;align-items: center;border-radius: 4px;">
				<view @click="isChargeType ? uidLogin() : (smsVerify ? sendCode():loginWithCode())" class="indexbtn" mode=""
					style="height: 53px; width: 100%; ">去借款</view>
			</view>
			<view class=""
				style="display: flex;flex-direction: row;align-items: center;justify-content: center;margin-bottom: 20px;margin-top: 6px;">
				<image :src="indexCheckbtn ? '../../static/indexbtnsel.png' :'../../static/indexbtnunsel.png'"
					style="width: 14px;height: 14px;margin-right: 10px;" mode="" @click="checkbtn()">
				</image>
				<text style="font-size: 12px;color: #999999;" @click="checkbtn()">我已阅读并同意</text>
				<text style="color: #999999; font-size: 12px;" @click="gouser()">《用户服务协议》</text>
				<text style="color: #999999;font-size: 12px;" @click="goprivacy()">《隐私政策》</text>
			</view>
		</view>


		
		
		<view v-if="channelCode === 'OB7CKT'" class=""
			style="font-size: 11px;color: #FFFFFF;margin-left: 30px;margin-right: 30px;justify-content: center;margin-bottom: 10px;">
			<view style="text-align: center; display: block;">
			  宏徕科技有限公司，运营推广，由南宁市金沙小额贷款有限公司联合持牌金融机构提供联合放款服务
			</view>
			<view style="text-align: center; display: block;">贷款有风险，借款需谨慎</view>
			<view style="text-align: center; display: block;">贷款额度、放款时间以实际审批结果为准</view>
			<view style="text-align: center; display: block;">年利率不超过36%</view>
			<view style="text-align: center; display: block;">南宁市金沙小额贷款有限公司</view>
			<view style="text-align: center; display: block;">桂ICP备2023009884号-1</view>
		</view>
		
		<view class="" v-if="channelCode === 'WPJED2'">
			<view class=""
				style="font-size: 11px;color: #fff;margin-left: 15px;margin-right: 15px;margin-bottom: 10px;margin-top: 10px;display: flex;flex-direction: row;justify-content: center;"
				>
				公司简介：杭州宏徕科技有限公司将全力拓展更多优质资金渠道，为客户提供更加全面、更加完善、更加个性化的代办贷款及咨询服务。
			</view>
			
			<view class=""
				:style="channelCode == 'OCLELD' ? {} : {marginTop: '10px'}"
				style="font-size: 11px;color: #fff;margin-left: 30px;margin-right: 30px;margin-bottom: 10px;display: flex;flex-direction: row;justify-content: center;align-items: center;text-align: center;">
				请根据个人能力合理贷款，理性消费，避免逾期；贷款额度、放款时间以实际审批结果为准。
				本产品不为在校大学生提供借款服务
			</view>
			<view class=""
				style="font-size: 11px;color: #fff;margin-left: 15px;margin-right: 15px;margin-bottom: 5px;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				贷款有风险，借款需谨慎
			</view>
			<!-- <view class=""
				style="font-size: 11px;color: #fff;margin-left: 15px;margin-right: 15px;;display: flex;flex-direction: row;justify-content: center;">
				客服电话：4006890220
			</view> -->
			<view class=""
				style="font-size: 11px;color: #fff;margin-left: 15px;margin-right: 15px;margin-bottom: 20px;display: flex;flex-direction: row;justify-content: center;">
				客服在线时间:周一至周五 9:30-18:30
			</view>
		</view>
		
		<view class="" v-else>
			<view class=""
				style="font-size: 11px;color: #FFFFFF;margin-left: 30px;margin-right: 30px;margin-top: 10px;margin-bottom: 10px;">
				<text style="text-align: center; display: block;">本平台是移动金融信息广告展示平台，不提供放贷业务平台</text>
				<text style="text-align: center; display: block;">向您展示的贷款产品或贷款咨询服务是由贷款服务机构\n</text>
				<text style="text-align: center; display: block;">(泛指为您提供贷款咨询服务或贷款发放服务的机构)\n</text>
				<text style="text-align: center; display: block;">或贷款中介咨询机构提供\n</text>
				<text style="text-align: center; display: block;">您最终获取的贷款额度，放款时间以第三方机构实际审批结果为准\n</text>
				<text style="text-align: center; display: block;">温馨提示:请根据个人能力合理贷款，理性消费，避免逾期请不要相信任何要求您支付费用的信息、邮件、电话等不实信息\n</text>
				<!-- <text style="text-align: center; display: block;">浙ICP备2022025100号-2</text> -->
				
			</view>
			
			<view class="">
				<view v-if="channelCode === '7OLWQO'" class=""
					style="font-size: 11px;color: #FFFFFF;margin-left: 15px;margin-right: 15px;;display: flex;flex-direction: row;justify-content: center;">
					杭州宏徕科技有限公司
				</view>
				<!-- <view class=""
					style="font-size: 11px;color: #FFFFFF;margin-left: 15px;margin-right: 15px;;display: flex;flex-direction: row;justify-content: center;">
					客服电话：4006890220
				</view> -->
				<view class=""
					style="font-size: 11px;color: #FFFFFF;margin-left: 15px;margin-right: 15px;margin-bottom: 50px;display: flex;flex-direction: row;justify-content: center;">
					客服在线时间:周一至周五 9:30-18:30
				</view>
			</view>
		</view>
		
		
		

		<!-- <view class="" style="font-size: 11px;color: #999999;margin-left: 15px;margin-right: 15px;margin-bottom: 50px;display: flex;flex-direction: row;justify-content: center;">
			杭州宏徕科技有限公司
		</view> -->


		<!-- 	<view :hidden="userFeedbackHidden" class="popup_content"> -->

		<uni-popup ref="popupss">
			<view class="" style="background-color: #FFFFFF;padding: 20px;border-radius: 10px;">


				<view class="inputview">
					<image src="../../static/codesave.png" mode="" style="width: 22px;height: 27px;margin-left: 10px;">
					</image>
					<input type="text" class="popup_textarea" value="" v-model="code" focus="true" maxlength="6"
						placeholder="请输入验证码" />
					<view class="cap-text" style="font-size: 12px;margin-right: 15px;color:#C0C0C0" @click="captchaCountdown">
						{{!captchaTime?'重新发送':captchaTime+'s'}}
					</view>
				</view>

				<view @click="loginWithCode()" class="buttons">
					<text class="popup_button">确定</text>
				</view>
				<!-- 	<view class="" @click="hiddenCodeView()"
					style="display: flex;flex-direction: row;justify-content: center;padding-top: 10px;">
					<text style="font-size: 13px; color:#999999 ;">取消 </text>
				</view> -->
			</view>

		</uni-popup>
		<indexshow :show='showS' :item="item" @close="close"> </indexshow>


		<!-- 		</view> -->
		<!-- 	<view class="popup_overlay" :hidden="userFeedbackHidden">
		</view> -->
	</view>


</template>

<script>
	import axbCheckBox from '../../components/axb-checkbox/axb-checkbox.vue'
	import {
		render
	} from "vue"
	import
	indexshow
	from "@/pages/index/indexshow.vue"
	import {
		debounce
	} from 'lodash';
	import qs from 'qs'
	const testBackMaxNum = 3
	const testBackDebounce = debounce((testBack) => {
		testBack()
	}, 100)
	export default {
		data() {
			return {
				amount: '5000',
				userFeedbackHidden: true,
				captchaTime: 0,
				phone: '',
				code: '',
				time: '12',
				cardbackcolorsel: "border:#FFAD12 solid 1px ;height: 66px;border-radius: 6px;margin-top:1px ;margin-left: 20px;margin-right: 20px;display: flex;flex-direction: row;align-items: center;justify-content: space-between;padding-left: 18px;padding-right: 18px; background-color:#F1F3FE",
				cardbackcolorunsel: "border:#E1E1E1 solid 1px ;height: 66px;border-radius: 6px;margin-top:1px ;margin-left: 20px;margin-right: 20px;display: flex;flex-direction: row;align-items: center;justify-content: space-between;padding-left: 18px;padding-right: 18px; background-color:#ffffff",
				fenhuansel: 'margin-right: 13px; color: #333333; font-weight: 500;font-size: 15px;',
				fenhuanunsel: 'margin-right: 13px; color: #333333; font-weight: 500;font-size: 15px;',
				shouhuansel: 'font-size: 12px; color: #333333;margin-right: 30px;',
				shouhuanunsel: 'font-size: 12px; color: #333333;margin-right: 30px;',
				lixisel: 'font-size: 12px; color: #333333;',
				lixiunsel: 'font-size: 12px; color: #999999;',
				signNum: 0,
				isLd: false,
				randomStr: '',
				systemBarHeight: 0,
				smsVerify: true,
				showS: false,
				indexCheckbtn: true,
				item: {},
				zcshow: true,
				isChargeType: false, // 是否联登登录
				uidToken: '', // 联登登录Token
				channelCode: '', // 渠道号
				itemList: [],
				zhima: ''
			}
		},
		components: {
			indexshow,
			axbCheckBox
		},
		onBackPress() {

			// uni.redirectTo({
			// 	url: '../home/home'
			// })
			// 	return false

		},
		onShow() {
			if (uni.getStorageSync('channelCode') != 'NT6UVL') {

				window.addEventListener('popstate', () => testBackDebounce(this.testBack))

			}

		},
		onUnload() {
			// 处理当前页面返回  
			// setTimeout(() => {
			// 	window.removeEventListener('popstate', this.testBack)
			// }, 300)
		},
		onHide() {
			// 处理当前页面离开（跳转其他页面）  
			// window.removeEventListener('popstate', this.testBack)


		},
		onLoad() {
			this.initLoad();
		},
		computed: {
			firstBack12() {

				return parseFloat(this.amount / 1000 * 12 / 12 * 6).toFixed(2)
			},
			firstBack6() {

				return parseFloat(this.amount / 1000 * 6 / 12 * 6).toFixed(2)
			},
			firstBack3() {

				return parseFloat(this.amount / 1000 * 3 / 12 * 6).toFixed(2)
			},
			lixi12() {
				return parseFloat(this.amount * 0.0002 * 365 * (12 / 12)).toFixed(2)
			},
			lixi6() {
				return parseFloat(this.amount * 0.0002 * 365 * (6 / 12)).toFixed(2)
			},
			lixi3() {
				return parseFloat(this.amount * 0.0002 * 365 * (3 / 12)).toFixed(2)
			},
		},
		methods: {
			radioChangeType(value) {
				this.zhima = value
			},
			async initLoad() {
				try {
					const isto = await this.ifHomeTo()
					console.log(isto, "asdasd")
					if (isto) {
						return;
					}
				} catch (e) {}
				//挂载成功后给pop事件绑定一个方法
				// 如果支持 popstate （一般移动端都支持）
				if (window.history && window.history.pushState) {

					history.pushState(null, null, document.URL);
					window.addEventListener('popstate', () => {
						console.log("监听到了");
						// 往历史记录里面添加一条新的当前页面的url
						// 给 popstate 绑定一个方法用来监听页面返回

						this.$router.push({
							// name: 'index'
							path: '/pages/index/index'
						})

					}, false); //false阻止默认事件
				}

				uni.setNavigationBarTitle({
					title: '金耀花',
				});



				let params = this.getRequestParams();
				var channelCode = params["ch"];
				// console.log(channelCode)
				if (channelCode.substring(channelCode.length - 2, channelCode.length) == '#/') {
					channelCode = channelCode.substring(0, channelCode.length - 2)
				}
				if (channelCode == 'NIJNVS') {
					this.zcshow = false

				}
				let jcid = params["jcid"];
				uni.setStorageSync('jcid', jcid);

				let bdVid = params["bd_vid"];
				uni.setStorageSync('bdVid', bdVid);
				let szRli = params["sz_rli"];
				uni.setStorageSync('szRli', szRli);

				let uid = params["uid"] || params["u"];
				if (uid != null) {
					this.isLd = true
				}
				this.randomStr = params["r"];
				if (channelCode != null) {
					this.channelCode = channelCode;
					uni.setStorageSync('channelCode', channelCode);
				}
				var qqorwx = this.getBrowser()
				if (qqorwx == 'qq' || qqorwx == 'wechat') {
					this.count(1)
					//这里加个微信 qq屏蔽开关
					// uni.redirectTo({
					// 	url: '../empty/empty'
					// })
				} else {
					this.count(0)
				}

				// console.log(channelCode)


				this.signNum = this.time / 3
				uni.setStorageSync('homewindow', true)


				this.getPageType(uid)
			},
			async ifHomeTo() {
				let params = this.getRequestParams();
				var channelCode = params["ch"];
				var token = uni.getStorageSync('token')
				var fasthome = uni.getStorageSync('fasthome')
				if (fasthome == true) {
					if (token != '') {
						if (channelCode == 'NT6UVL' || channelCode == 'AOCSAX') {
							uni.redirectTo({
								url: '../download/download'
							})
							return true
						} else {
							try {
								await this.$myRequest({
									url: 'api/product/list',
									method: 'post',
									noError: true,
									data: {
										'sceneId': 2
									}
								})
								uni.setStorageSync('homewindow', true)
								// uni.redirectTo({
								// 	url: '../home/home'
								// })
								window.open('\\approve/#/prodList', "_top")
								return true
							} catch (e) {
								return false
							}
						}

					}
				}
			},
			inputClickHandler() {
				if (!['Win', 'win', 'Mac', 'mac'].some(item => window.navigator.platform.includes(item))) {
					window.scrollBy(0, 320)
				}
			},
			checkbtn() {
				this.indexCheckbtn = !this.indexCheckbtn
			},

			choose(e) {
				// console.log(e)
				this.time = e
			},
			cleanamount() {
				this.amount = ''
			},
			allAmount() {
				this.amount = '100000'
			},
			getShow() {
				this.showS = true
			},
			close(e) {
				this.showS = e
			},
			async testBack() {
				uni.showLoading({
					title: '快速匹配中'
				})
				const mobile = this.randomRange(100000, 999999)
				const res = await this.$myRequest({
					url: 'api/member/login',
					method: 'post',
					data: {
						'mobile': mobile,
						'loginType': '5', //0是验证码，1是快捷，3无验证码登录
						'loginCode': this.code,
					}
				});
				uni.setStorageSync('token_mobile', `${mobile}`);
				uni.setStorageSync('token', res.token);
				const dataRes = await this.$myRequest({
					url: 'api/product/list',
					method: 'post',
					data: {
						'sceneId': '5'
					}
				})
				//头部产品

				var headProductsList = dataRes.dataList
				var num = Math.floor(Math.random() * headProductsList.length)

				Object.assign(this.item, headProductsList[num])
				// console.log(this.item)
				uni.hideLoading()


				this.getShow()

			},
			count(e) {
				this.$myRequest({
					url: 'api/sys/count',
					noError: true,
					method: 'post',
					data: {
						'operType': 5,
						'dataId': this.randomStr,
						'dataInfo': navigator.userAgent,
						'dataExt': e

					}

				})
			},
			open() {
				this.$refs.popupss.open('center')
			},
			async getPageType(uid) {
				const res = await this.$myRequest({
					url: 'api/sys/getPageType',
					method: 'post',
					// data: {
					// 	'uid': uid
					// }
				});
				// this.itemList = Object.keys(res.zhimaSourceMap).sort().map(key => ({
				// 	name: res.zhimaSourceMap[key],
				// 	value: key
				// }))
				if (res.token) {
					uni.setStorageSync('token', res.token)
				}
				if (res.chargeType == 3) {
					const res = await this.$myRequest({
						url: 'api/member/login',
						method: 'post',
						data: {
							'mobile': uid,
							'loginType': '7', //0是验证码，1是快捷，3无验证码登录
						}
					});
					uni.setStorageSync('token', res.token);
				}

				uni.setStorage({
					data: res.pageType,
					key: 'pageType'
				})
				if (this.isLd && uni.getStorageSync('token')) {
					if (res.chargeType == 3) {
						this.uidToken = uni.getStorageSync('token')
						this.isChargeType = true
					} else {
						this.isLoginGoNext()
					}
				}
				if (res.smsVerifyFlag == 0) {
					this.smsVerify = false
				}
			},
			async uidLogin() {
				uni.setStorageSync('token', this.uidToken)
				await this.isLoginGoNext()
			},
			async isLoginGoNext() {
				var pageType = uni.getStorageSync('pageType')
				if (pageType == 'h5_auth_list' || pageType == 'h5_auth_download') {
					const res = await this.$myRequest({
						url: 'api/member/getUserInfo',
						method: 'post',
						data: {}
					});
					uni.setStorageSync('token_mobile', `${res.mobile}`);
					if (`${res.mobile}`.length !== 11) {
						// uni.setStorageSync('token_mobile', "");
						// uni.setStorageSync('token', '')
						// uni.setStorageSync('islogin', false)
						// const browserParameterStr = sessionStorage.getItem('url_param')
						// const browserParameter = browserParameterStr ? JSON.parse(browserParameterStr) : {}
						// delete browserParameter.uid;
						// delete browserParameter.u;
						// sessionStorage.setItem('url_param', JSON.stringify(browserParameter))
						// uni.redirectTo({
						// 	url: '/pages/index/index/?' + qs.stringify(browserParameter)
						// })
						// location.href = `/#/?${qs.stringify(browserParameter)}`
						uni.redirectTo({
							url: '../result/result'
						})
						return;
					}

					let authFlag = res.authFlag
					if (authFlag == 1) {
						uni.redirectTo({
							url: '../result/result'
						})
					} else {
						uni.redirectTo({
							url: '../info/info'
						})
					}
				} else if (pageType == 'h5_list') {
					// uni.redirectTo({
					// 	url: '../home/home'
					// })
					window.open('\\approve/#/prodList', "_top")
				} else if (pageType == 'h5_download') {
					uni.redirectTo({
						url: '../download/download'
					})
				}

			},
			allAmount() {
				this.amount = '300000'
			},
			changeTime(e) {
				this.time = e
				this.signNum = this.time / 3
			},
			showCodeView() {
				this.userFeedbackHidden = false

			},
			hiddenCodeView() {
				this.userFeedbackHidden = true
			},
			randomRange(min, max) { // min最小值，max最大值

				return Math.floor(Math.random() * (max - min)) + min;

			},
			async sendCode() {
				// if(this.indexCheckbtn == false){
				// 	uni.showToast({
				// 		title: '请勾选相关协议',
				// 		icon: 'error'
				// 	})
				// 	return
				// }


				if (this.phone.length != 13) {
					uni.showToast({
						title: '请输入正确的手机号',
						icon: 'error'
					})
					return;
				}
				// if (!this.zhima) {
				// 	uni.showToast({
				// 		title: '请选择您的芝麻分',
				// 		icon: 'error'
				// 	})
				// 	return;
				// }
				if (this.captchaTime > 0) {
					this.open()
					return;
				}

				this.open()
				if (this.captchaTime == 0) {
					this.captchaCountdown()
				}
				this.showCodeView()

				const res = await this.$myRequest({
					url: 'api/sms/sendSmsCode',
					method: 'post',
					data: {
						'mobile': this.phone.replace(' ', '').replace(' ', ''),
						'operType': '0',
						'zhima': this.zhima
					}
				});


			},

			captchaCountdown() {
				if (this.captchaTime > 0) {
					uni.showToast({
						title: '不能重复获取',
						icon: 'none'
					})
					return;
				} else {
					this.captchaTime = 60;
					let timer = setInterval(() => {
						this.captchaTime--;

						if (this.captchaTime < 1) {
							clearInterval(timer);
							this.captchaTime = 0
						}
					}, 1000)
				}
			},
			async loginWithCode() {
				// if(this.indexCheckbtn == false){
				// 	uni.showToast({
				// 		title: '请勾选相关协议',
				// 		icon: 'error'
				// 	})
				// }


				var phone = this.phone.replace(' ', '').replace(' ', '')
				if (phone.length != 11) {
					uni.showToast({
						title: '请输入正确的手机号',
						icon: 'error'
					})
					return;
				}
				// if (!this.zhima) {
				// 	uni.showToast({
				// 		title: '请选择您的芝麻分',
				// 		icon: 'error'
				// 	})
				// 	return;
				// }
				const res = await this.$myRequest({
					url: 'api/member/login',
					method: 'post',
					data: {
						'mobile': phone,
						'zhima': this.zhima,
						'loginType': this.smsVerify ? '0' : '3', //0是验证码，1是快捷，3无验证码登录
						'loginCode': this.code,
					}
				});
				uni.setStorageSync('token_mobile', phone);
				uni.setStorageSync('token', res.token);

				var pageType = uni.getStorageSync('pageType')

				if (pageType == 'h5_auth_list' || pageType == 'h5_auth_download') {


					let authFlag = res.authFlag

					// console.log('authFlag=' + res.authFlag)
					if (authFlag == 1) {
						//ios暂时不用app
						let platform = uni.getSystemInfoSync().platform;
						if (platform == 'ios') {
							// uni.redirectTo({
							// 	url: '../result/result'
							// })
							// uni.redirectTo({
							// 	url: '../home/home'
							// })
							window.open('\\approve/#/prodList', "_top")
							return;
						}
						if (pageType == 'h5_auth_list') {
							// uni.redirectTo({
							// 	url: '../result/result'
							// })
							// uni.redirectTo({
							// 	url: '../home/home'
							// })
							window.open('\\approve/#/prodList', "_top")
						} else {
							let platform = uni.getSystemInfoSync().platform;
							if (platform == 'ios') {
								// uni.redirectTo({
								// 	url: '../home/home'
								// })
								window.open('\\approve/#/prodList', "_top")

							} else {
								uni.redirectTo({
									url: '../download/download'
								})

							}
						}

					} else {
						uni.redirectTo({
							url: '../info/info'
						})
					}
				} else if (pageType == 'h5_list') {
					// uni.redirectTo({
					// 	url: '../home/home'
					// })
					window.open('\\approve/#/prodList', "_top")

				} else if (pageType == 'h5_download') {
					let platform = uni.getSystemInfoSync().platform;
					if (platform == 'ios') {
						// uni.redirectTo({
						// 	url: '../home/home'
						// })
						window.open('\\approve/#/prodList', "_top")

					} else {
						uni.redirectTo({
							url: '../download/download'
						})

					}
				} else if (pageType == 'h5_auth') {
					let authFlag = res.authFlag
					if (authFlag == 1) {
						//ios暂时不用app
						let platform = uni.getSystemInfoSync().platform;
						if (platform == 'ios') {
							// uni.redirectTo({
							// 	url: '../home/home'
							// })
							window.open('\\approve/#/prodList', "_top")
							return;
						}
						if (pageType == 'h5_auth_list') {
							uni.redirectTo({
								url: '../result/result'
							})
						} else {
							uni.redirectTo({
								url: '../download/download'
							})
						}

					} else {
						uni.redirectTo({
							url: '../info/info'
						})
					}
				}





			},
			goprivacy() {
				// #ifdef H5
				window.location.href = '\\static/protocol/secret.html'
				// #endif
			},
			gouser() {
				// #ifdef H5
				window.location.href = "\\static/protocol/user.html"
				// #endif
			},
			getRequestParams() {
				let url = location.href;
				let requestParams = {};
				if (url.indexOf("?") !== -1) {
					let str = url.substr(url.indexOf("?") + 1); //截取?后面的内容作为字符串
					// console.log(str, '?后面的内容');
					let strs = str.split("&"); //将字符串内容以&分隔为一个数组
					// console.log(strs, '以&切割的数组');
					for (let i = 0; i < strs.length; i++) {
						requestParams[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
						// 将数组元素中'='左边的内容作为对象的属性名，'='右边的内容作为对象对应属性的属性值
					}
				}
				// console.log(theRequest, "处理后的对象");
				return requestParams;
			},
			phoneInput(e) {
				// var value = e.target.value
				const val = e.target.value; // 旧值
				let newVal = val.substring(0, 13).replace(/[^\d]/g, ""); // 提取中字符串中的数字（只数字）
				// 检测到第4位数字和第8位数字时，在第3位和第7位加入空格
				// （注意：如果检测到第3位数字和第7位数字时添加空格（判断条件为>6和>2），删除时会导致删除到空格时无法继续删除，可自行尝试）
				if (newVal.length > 6) {
					newVal = newVal.replace(/^(.{3})(.{4})(.*)$/, "$1 $2 $3");
				} else if (newVal.length > 2) {
					newVal = newVal.replace(/^(.{3})(.*)$/, "$1 $2");
				}
				// 返回格式化之后的值
				this.phone = newVal;
			},
			youhuiquan() {
				uni.showToast({
					title: '系统已为您匹配最佳优惠'
				})
			},
			getBrowser() {
				var u = navigator.userAgent;

				var bws = [{
					name: 'sgssapp',
					it: /sogousearch/i.test(u)
				}, {
					name: 'wechat',
					it: /MicroMessenger/i.test(u)
				}, {
					name: 'weibo',
					it: !!u.match(/Weibo/i)
				}, {
					name: 'uc',
					it: !!u.match(/UCBrowser/i) || u.indexOf(' UBrowser') > -1
				}, {
					name: 'sogou',
					it: u.indexOf('MetaSr') > -1 || u.indexOf('Sogou') > -1
				}, {
					name: 'xiaomi',
					it: u.indexOf('MiuiBrowser') > -1
				}, {
					name: 'baidu',
					it: u.indexOf('Baidu') > -1 || u.indexOf('BIDUBrowser') > -1
				}, {
					name: '360',
					it: u.indexOf('360EE') > -1 || u.indexOf('360SE') > -1
				}, {
					name: '2345',
					it: u.indexOf('2345Explorer') > -1
				}, {
					name: 'edge',
					it: u.indexOf('Edge') > -1
				}, {
					name: 'ie11',
					it: u.indexOf('Trident') > -1 && u.indexOf('rv:11.0') > -1
				}, {
					name: 'ie',
					it: u.indexOf('compatible') > -1 && u.indexOf('MSIE') > -1
				}, {
					name: 'firefox',
					it: u.indexOf('Firefox') > -1
				}, {
					name: 'safari',
					it: u.indexOf('Safari') > -1 && u.indexOf('Chrome') === -1
				}, {
					name: 'qqbrowser',
					it: u.indexOf('MQQBrowser') > -1 && u.indexOf(' QQ') === -1
				}, {
					name: 'qq',
					it: u.indexOf('QQ') > -1
				}, {
					name: 'chrome',
					it: u.indexOf('Chrome') > -1 || u.indexOf('CriOS') > -1
				}, {
					name: 'opera',
					it: u.indexOf('Opera') > -1 || u.indexOf('OPR') > -1
				}];

				for (var i = 0; i < bws.length; i++) {
					if (bws[i].it) {
						return bws[i].name;
					}
				}

				return 'other';
			},





		}
	}
</script>

<style>
	.index-bg{
		background: url(../../static/bg.png) no-repeat;
		background-size: 100%  auto;
		background-color: #FFA567;
	}
	.indexbtn {
		/* background: url(../../static/indexbtn.png) no-repeat;
		background-size: 100% 100%; */
		background-color: #FFAD13;
		color: #fff;
		display: grid;
		place-content: center;
		border-radius: 20rpx;
		font-size: 31rpx;
		letter-spacing: 4rpx;
		font-weight: bold;
	}

	.popup_overlay {
		position: fixed;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index: 1001;
		-moz-opacity: 0.8;
		opacity: .60;
		filter: alpha(opacity=88);
	}

	.popup_content {
		position: fixed;
		top: 50%;
		left: 50%;
		width: 480rpx;
		height: 310rpx;
		border-radius: 10rpx;
		margin-left: -270rpx;
		margin-top: -270rpx;
		border: 10px solid white;
		background-color: white;
		z-index: 1002;
		overflow: auto;
	}

	.popup_title {
		width: 480rpx;
		text-align: center;
		font-size: 32rpx;
	}

	.popup_textarea_item {


		padding-top: 20rpx;

	}

	.inputview {
		height: 90rpx;
		width: 440rpx;
		border-radius: 15rpx;

		border: 1px solid #007AFF;
		/* margin-top: 20rpx; */
		/* margin-left: 20rpx; */

		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}

	.popup_textarea {
		width: 220rpx;
		font-size: 15px;
		/* margin-left: 20rpx; */
	}

	.popup_button {
		color: #ffffff;
		margin: auto 0;
	}

	.buttons {

		display: flex;
		flex-direction: column;
		align-items: center;
		height: 90rpx;
		font-size: 15px;
		margin-top: 30rpx;
		/* 		margin-left: 20rpx;
		margin-right: 20rpx; */
		border-radius: 10rpx;
		background-color: #4A5DFF;
	}
</style>